package top.tagao;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Random;

public class Main {
    public static void main(String[] args) {
        for (int i = 0; i < 100; i++) {
            // 设置起始日期和结束日期
            Calendar startCal = Calendar.getInstance();
            startCal.set(2023, Calendar.JULY, 5, 0, 0, 0);
            Calendar endCal = Calendar.getInstance();
            endCal.set(2023, Calendar.SEPTEMBER, 10, 23, 59, 59);

            // 生成随机日期
            Random random = new Random();
            long startTimeMillis = startCal.getTimeInMillis();
            long endTimeMillis = endCal.getTimeInMillis();
            long randomTimeMillis = startTimeMillis + (long) (random.nextDouble() * (endTimeMillis - startTimeMillis));
            Calendar randomCal = Calendar.getInstance();
            randomCal.setTimeInMillis(randomTimeMillis);

            // 生成随机小时、分钟和秒数
            int randomHour = random.nextInt(24);
            int randomMinute = random.nextInt(60);
            int randomSecond = random.nextInt(60);

            // 设置随机小时、分钟和秒数
            randomCal.set(Calendar.HOUR_OF_DAY, randomHour);
            randomCal.set(Calendar.MINUTE, randomMinute);
            randomCal.set(Calendar.SECOND, randomSecond);

            // 格式化日期为字符串
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String formattedDate = sdf.format(randomCal.getTime());

            System.out.println("随机日期时间：" + formattedDate);

        }
    }
}